package example

import (
	"log"
	"net/http"
	_ "net/http/pprof"
	"os"
	"os/signal"
	"syscall"
	"time"
)

func T2(){
	ip := "127.0.0.1:6060"
	go func() {
		if err := http.ListenAndServe(ip, nil);err !=nil{
			log.Fatalln("start server failed")
		}
	}()
	http.HandleFunc("/test", handler)

	c := make(chan os.Signal, 1)
	signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
	for{
		s := <- c
		switch s {
		case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
			time.Sleep(time.Second)
			return
		case syscall.SIGHUP:
		default:
			return
		}
	}
}

func handler(w http.ResponseWriter, r *http.Request) {
	ch := make(chan int, 1)
	go func() {
		<-ch
		println("handler send")
	}()
}